package com.wawei.seeds.me;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;

import com.wawei.seeds.R;
import com.wawei.seeds.adapter.SeedsBaseAdapter;
import com.wawei.seeds.adapter.WalnutAppointmentFragmentAdapter;
import com.wawei.seeds.champion.ChampionActivity;
import com.wawei.seeds.model.WalnutMainEvent;
import com.wawei.seeds.services.ServiceHandler;
import com.wawei.seeds.services.WalnutAppointmentServiceHandler;

import java.io.Serializable;

/**
 *
 * Created by t27891 on 15/6/21.
 */
public class MeAppointmentFragment extends MeBaseFragment {

    private WalnutAppointmentServiceHandler serviceHandler;
    private WalnutAppointmentFragmentAdapter appointmentAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        serviceHandler = new WalnutAppointmentServiceHandler(getActivity());
        appointmentAdapter = new WalnutAppointmentFragmentAdapter(getActivity());
    }

    @Override
    public View onCreateViewBeforeInjection(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //return null for using default layout
        return null;
    }

    @Override
    public void onCreateViewAfterInjection(View view, LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    }

    @Override
    public String getTitle() {
        return getString(R.string.walnut_me_appointment);
    }

    @Override
    public void onViewCreatedAfterTitle(View view, Bundle savedInstanceState) {
    }

    @Override
    public Bundle makeConditionBundle(int phase) {
        return null;
    }

    @Override
    public SeedsBaseAdapter<WalnutMainEvent> makeListAdapter() {
        return appointmentAdapter;
    }

    @Override
    public ServiceHandler makeServiceHandler() {
        return serviceHandler;
    }

    @Override
    public Intent makeIntent4ListItemClicked(AdapterView<?> parent, View view, int position, long id, Object itemData) {
        Intent intent = new Intent(getActivity(), ChampionActivity.class);
        intent.putExtra(ChampionActivity.ITEM_DATA, (Serializable)itemData);
        return intent;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    public void onDestroy() {
        serviceHandler = null;
        appointmentAdapter.clear();
        appointmentAdapter = null;
        super.onDestroy();
    }

    @Override
    public void onResume() {
        super.onResume();
    }
}
